<!DOCTYPE html>
<html lang="en">
	<head>
    	<meta name="layout" content="main_mobile">
        <title>火堆</title>
        <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
        <script type="text/javascript">
	    wx.config({
	 	    debug: false,  // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
	 	    appId: '${appid}', // 必填，公众号的唯一标识
	 	    timestamp: "${timestamp}", // 必填，生成签名的时间戳
	 	    nonceStr: '${nonceStr}', // 必填，生成签名的随机串
	 	    signature: '${signature}',// 必填，签名，见附录1
	 	    jsApiList: ['checkJsApi' , 'onMenuShareAppMessage' , 'onMenuShareTimeline']
	 	});

	 	wx.ready(function(){
	 		wx.checkJsApi({
	 		    jsApiList: ['onMenuShareAppMessage' , 
	 			 		    'onMenuShareTimeline'
	 		              ], // 需要检测的JS接口列表，所有JS接口列表见附录2,
	 		    success: function(res) {
	 		       //alert('wx.check: '+JSON.stringify(res));
	 		    }
	 		});
	 		//发送给朋友分享功能
	 		wx.onMenuShareAppMessage({
	 		    title: '${user?.nickname}邀请你进入火堆公益众筹，一起助力教育', // 分享标题
	 		    desc: '关注火堆，为教育发声！', // 分享描述
	 		    link: '${shareUrl}', // 分享链接
	 		    imgUrl: '${imgUrl}', // 分享图标
				trigger: function () {
				//alert("点击按钮");
				},
	 		    success: function () { 
	 		        // 用户确认分享后执行的回调函数
	 		        $('.wx-share-box').removeClass('show');
	 		    },
	 		    cancel: function () { 
	 		        // 用户取消分享后执行的回调函数
	 		    	$('.wx-share-box').removeClass('show');
	 		    }
	 		});

	 		//分享到朋友圈
	 		wx.onMenuShareTimeline({
	 		    title: '${user?.nickname}邀请你进入火堆公益众筹，一起助力教育', // 分享标题
	 		    link: '${shareUrl}', // 分享链接
	 		    imgUrl: '${imgUrl}',  // 分享图标
	 		    success: function () { 
	 		        // 用户确认分享后执行的回调函数
	 		    	$('.wx-share-box').removeClass('show');
	 		    },
	 		    cancel: function () { 
	 		        // 用户取消分享后执行的回调函数
	 		    	$('.wx-share-box').removeClass('show');
	 		    }	
	 		});
	 	});
	 	wx.error(function (res) {
			//alert('wx.error: '+JSON.stringify(res));
	    });
	</script>       
     <link rel="stylesheet" href="${resource(dir: 'css', file: 'index.css')}" type="text/css">
     <link rel="stylesheet" href="${resource(dir: 'css', file: 'search.css')}" type="text/css">
     <style>
     </style>  
    </head>
<body>
     <div class="ui-footer ui-footer-navi ui-btn-group ui-border-t">
      <a href="/scfire" class="active"><i class="i1"></i><div>首页</div></a>
      <a href="/scfire/project/fundPoolList"><i class="i2"></i><div>爱心池</div></a>
      <a href="/scfire/project/start"><i class="i3"></i><div>发起项目</div></a>
      <a href="/scfire/user/userCenter"><i class="i4"></i><div>个人中心</div></a>
    </div>
	<div class="ui-container">
	<div id="wrapper">
	<div class="page-search" data-log="搜索页">
	<div class="header">
	<div class="ui-searchbar-wrap ui-border-b">
    <div class="ui-searchbar ui-border-radius">
        <i class="ui-icon-search"></i>
        <div class="ui-searchbar-text">搜索请输入项目名</div>
        <div class="ui-searchbar-input"><input value="" type="tel" placeholder="搜索请输入项目名或类型" autocapitalize="off"></div>
        <i class="ui-icon-close"></i>
    </div>
    <button class="ui-searchbar-cancel">取消</button>
    </div>
	</div><!--vue-if-->
	<div class="status">
        <div id="running" class="li sel" v="1">筹集中</div>
        <div id="run" class="li " v="2">执行中</div>
        <div id="end"  class="li " v="3">已结项</div>
    </div>
	<div>
	</div><!--vue-if--></div><!--v-view--></div>
	 <div class="list" id="showdata">
		</div>     
    </div>
    <div style="text-align: center;margin-bottom: 5px">
    <li>
    	<a id="cz-more" href='javascript:;' class='btn-more' id='week' onclick='show()'>点击加载更多</a>
    	<a id="cz-end" href='javascript:;' class='btn-more' id='week' >已经到底了</a>
     </li>
     </div>
    <script src="/scfire/frozen/js/frozen.js"></script>
	<script type="text/javascript">
	function IsPC() 
 	{ 
 	var userAgentInfo = navigator.userAgent; 
 	var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); 
 	var flag = true; 
 	for (var v = 0; v < Agents.length; v++) { 
 	if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } 
 	} 
 	return flag; 
 	}


	
	var finalOffset= 20
	var offset = 0
	var sign=1
	$(function(){
		$("#cz-more").show();
    	$("#cz-end").hide();
    	show();
		})
		
	   $('.ui-searchbar').click(function(){
		   window.location.href='/scfire/project/projectsearch';
	    });
	    //ajax请求
	    $("#running").click(function(){
	    	 offset = 0;
	    	 sign=1;
	    	 $("#running").attr("class","li sel");
	    	 $("#run").attr("class","li ");
	    	 $("#end").attr("class","li ");
	    	 $("#showdata").empty();
	    	 moreend();
	    	 show();
		    });
	    $("#run").click(function(){
	    	 offset = 0;
	    	 sign=2;
	    	 $("#running").attr("class","li ");
	    	 $("#run").attr("class","li sel ");
	    	 $("#end").attr("class","li ");
	    	 $("#showdata").empty();
	    	 moreend();
	    	 show();
		    });
	    $("#end").click(function(){
	    	 offset = 0;
	    	 sign=3;
	    	 $("#running").attr("class","li ");
	    	 $("#run").attr("class","li ");
	    	 $("#end").attr("class","li sel");
	    	 $("#showdata").empty();
	    	 moreend();
	    	 show();
		    });
	      function moreend(){
	    	$("#cz-more").show();
	      	$("#cz-end").hide();
	      	}
          function show(){
			var html="";
	        var el;
	       
			$.ajax({ 
		    	data:{
	    	        sign:sign,
	    	        offset:offset
	    	    } ,
	    	    
	            type:'get',  
	            dataType:'json',
	            url:'/scfire/project/projectsignJson?format=json',         
	            beforeSend:function(){
		            	el=$.loading({
		    		        content:"加载中...",
		    		    });
	                },
	            success:function(data){
		            var flag = IsPC();
		            if(data.length==0){
		            	$("#cz-more").hide();
		            	$("#cz-end").show();
			            }else{
			            	if(data.length<20){
				            	$("#cz-more").hide();
				            	$("#cz-end").show();
					            }else{
					            	$("#cz-more").show();
					            	$("#cz-end").hide();
						            }
		            	 $.each(data,function(i,project){
			            	 if(flag==true){
				 	          		html+="<a href='/scfire/project/projectDetailPC?projectid="+project.id+"'>"
				            	 }else{
					 	          		html+="<a href='/scfire/project/projectDetail?projectid="+project.id+"'>"
					            	 }
		 	          		html+="<div class='item bg2'>"
		 	              	html+="<img class='fl' src='/scfire/project/imgRead?img="+project.img+"'>"  
		 	          		html+="<div class='t'><div class='tn'></div>"
		 	                html+="<div class='tt'><span>"+project.name+"</span></div>"
		 	                html+="<div class='td'>"+project.description+"</div> "
		 	                html+="<div class='tp'>共 <span style='color:#fb6e50;  font-size: 15px;'>"+project.donatenum+" </span>份爱心"  		
		 	          		html+="</div></div><div class='clear'></div></div>"
		 	          		html+="</a>"
		 	          	  });
			            }
	          	 $("#showdata").append(html);
	          	 el.loading("hide");
	          	 offset +=finalOffset; 
	            },  
	            complete:function(){},
	            error:function(data){
	            	el.loading("hide");
	            	el=$.loading({
	    		        content:"加载失败,请刷新重试",
	    		    });
	            }
	           
		      });  
			}
	</script>
</body>
</html>